/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <cstdio>
#include <vector>
using namespace std;

int main_1022()
{
    int A,B,D,S;
    scanf("%d%d%d",&A,&B,&D);
    S=A+B;
    vector<int> C;
    do
    {
        C.push_back(S%D);
        S/=D;
    } while (S!=0);
    for (auto it=C.rbegin();it!=C.rend() ;++it )
    {
        printf("%d",*it);
    }
    printf("\n");
	return 0;
}
